package com.hundsun.yr.universal.p2p.bean;

import java.io.Serializable;
import java.util.Date;

import android.text.TextUtils;

import com.hundsun.yr.universal.library.utils.HsDateUtils;
import com.hundsun.yr.universal.library.utils.HsNumberUtils;
import com.hundsun.yr.universal.library.utils.MathUtils;





/**
 * @Title: TradeDetail.java 
 * @Description: 交易详情
 * @date 2016-2-2 下午6:24:43 
 * @author:hejun.shen
 * @email:shenhj15971@hundsun.com 
 * @replace author:
 * @replace date:
 * @version V1.0   
 */
public class TradeDetail extends ResponseBean implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	/**
	 * 取值的key
	 */
	public static String BASEKEY="userTradeBizPojos";
	
	
	/**
	 * 是否为Section
	 */
	private boolean isSection;
	/**
	 * 年月(yyyy-MM)
	 */
	private String date;
	/**
	 * 年(yyyy)
	 */
	private String year;
	/**
	 * 月(MM)
	 */
	private String month ;
	/**
	 * 日期(MM-dd)
	 */
	private String day;
	/**
	 * 实际支付金额
	 */
	private float actuallyAmount ;
	/**
	 * 交易金额
	 */
	private String amount ;
	/**
	 * 订单状态（订单中心）
	 */
	private String orderCenterStatus ;
	/**
	 * 订单号
	 */
	private String orderId ;
	/**
	 * 项目
	 */
	private String product ;
	/**
	 * 交易状态
	 */
	private String status ;
	/**
	 * 交易时间
	 */
	private String tradeTime ;
	/**
	 * 交易类别
	 */
	private String type ;
	/**
	 * 今年
	 */
	private String thisYear ;
	/**本月**/
	private String thisMonth;
	/**
	 * 开始支付时间
	 */
	private String payStartTime ;
	
	/**
	 * 剩余支付时间
	 */
	private String remainTime ;
	/**
	 * 交易结束时间
	 */
	private String payEndTime ;
	public String getPayEndTime() {
		return payEndTime;
	}

	/**
	 * 获取结束时间
	 * @param outTime
	 * @return
	 */
	public String getPayEndTime(String outTime) {
		String endtime=MathUtils.plus(payStartTime,MathUtils.multiply(outTime,"60000"));
		return endtime;
	}
	public void setPayEndTime(String payEndTime) {
		this.payEndTime = payEndTime;
	}
	
	public String getRemainTime() {
		return remainTime;
	}

	public void setRemainTime(String remainTime) {
		this.remainTime = remainTime;
	}

	public String getPayStartTime() {
		return payStartTime;
	}

	public void setPayStartTime(String payStartTime) {
		this.payStartTime = payStartTime;
	}

	public String getThisMonth() {
		thisMonth=HsDateUtils.timeformat(HsDateUtils.farmat_month_1, new Date());
		return thisMonth;
	}

	public void setThisMonth(String thisMonth) {
		this.thisMonth = thisMonth;
	}

	public String getThisYear() {
		thisYear=HsDateUtils.timeformat(HsDateUtils.farmat_year, new Date());
		return thisYear;
	}

	public void setThisYear(String thisYear) {
		this.thisYear = thisYear;
	}

	/**
	 * 月份显示
	 * @return
	 */
	public String displayMonth(){
		if(TextUtils.equals(getThisMonth(), getDate())){
			return "本月";
		}else{
			
			if(TextUtils.equals(getThisYear(), getYear())){
				return month+"月";
			}else{
				return year+"年"+month+"月";
			}
		}
	}

	
	
	public boolean isSection() {
		return isSection;
	}

	
	public void setSection(boolean isSection) {
		this.isSection = isSection;
	}


	public String getDate() {
		date=HsDateUtils.timeformat(HsDateUtils.farmat_month_1, tradeTime);
		return date;
	}


	public void setDate(String date) {
		this.date = date;
	}


	public String getYear() {
		year=HsDateUtils.timeformat(HsDateUtils.farmat_year, tradeTime);
		return year;
	}


	public void setYear(String year) {
		this.year = year;
	}


	public String getMonth() {
		month =HsDateUtils.timeformat(HsDateUtils.farmat_month_2, tradeTime);
		return month;
	}


	public void setMonth(String month) {
		this.month = month;
	}


	public String getDay() {
		day=HsDateUtils.timeformat(HsDateUtils.farmat_day_1, tradeTime);
		return day;
	}


	public void setDay(String day) {
		this.day = day;
	}


	public float getActuallyAmount() {
		return actuallyAmount;
	}


	public void setActuallyAmount(float actuallyAmount) {
		this.actuallyAmount = actuallyAmount;
	}


	public String getAmount() {
		return amount;
	}


	public void setAmount(String amount) {
		this.amount = amount;
	}


	public String getOrderCenterStatus() {
		return orderCenterStatus;
	}


	public void setOrderCenterStatus(String orderCenterStatus) {
		this.orderCenterStatus = orderCenterStatus;
	}


	public String getOrderId() {
		return orderId;
	}


	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}


	public String getProduct() {
		return product;
	}


	public void setProduct(String product) {
		this.product = product;
	}


	public String getStatus() {
		return status;
	}


	public void setStatus(String status) {
		this.status = status;
	}


	public String getTradeTime() {
		return tradeTime;
	}

	/**
	 * 显示交易时间
	 * @return
	 */
	public String dispalyTradeTime(){
		String disTradeTime=HsDateUtils.timeformat(HsDateUtils.farmat_date_3, tradeTime);
		return disTradeTime;
	}

	public void setTradeTime(String tradeTime) {
		this.tradeTime = tradeTime;
	}


	public String getType() {
		return type;
	}


	public void setType(String type) {
		this.type = type;
	}


	
	/**
	 * 获取显示金额
	 * @return
	 */
	public String displayMoney(){
		String money=HsNumberUtils.moneyThousandsFormat(actuallyAmount);
		if(TextUtils.equals(type, OrderType.SALE)){
			money="-"+HsNumberUtils.moneyThousandsFormat(actuallyAmount);
		}else if(TextUtils.equals(type, OrderType.RECHARGE)){
			money="+"+HsNumberUtils.moneyThousandsFormat(actuallyAmount);
		}else if(TextUtils.equals(type, OrderType.WITHDRAW)){
			money="-"+HsNumberUtils.moneyThousandsFormat(actuallyAmount);
		}else if(TextUtils.equals(type, OrderType.REPAYMENT)){
			money="-"+HsNumberUtils.moneyThousandsFormat(actuallyAmount);
		}else if(TextUtils.equals(type, OrderType.CASH)){
			money="+"+HsNumberUtils.moneyThousandsFormat(actuallyAmount);
		}else if(TextUtils.equals(type, OrderType.LOAN)){
			money="+"+HsNumberUtils.moneyThousandsFormat(actuallyAmount);
		}
		
		return money;
	}
	
	
	/**
	 * 获取显示Section
	 */
	public String displaySection(){
		return "";
	}
	
	/**
	 * 订单状态
	 */
	public static final class OrderType{
		
		/**
		 * 投资
		 */
		public static final String SALE = "SALE";
		/**
		 * 充值
		 */
		public static final String RECHARGE = "RECHARGE";
		/**
		 * 提现
		 */
		public static final String WITHDRAW = "WITHDRAW";
		/**
		 * 还款
		 */
		public static final String REPAYMENT = "REPAYMENT";
		/**
		 * 兑付 (回款)
		 */
		public static final String CASH = "CASH";
		/**
		 * 放款
		 */
		public static final String LOAN = "LOAN";
		
	}
	
	
	/**
	 * 交易类别
	 */
	public enum EnumOrderType {
		SALE("SALE","投资"),
		RECHARGE("RECHARGE","充值"),
		WITHDRAW("WITHDRAW","提现"),
		REPAYMENT("REPAYMENT","还款"),
		CASH("CASH","回款"),
		LOAN("LOAN","放款");

	    /** 状态描述 **/
	    private String description;
	    /** 状态 **/
	    private String status;

	    /**
	     * 私有构造方法
	     * @param description 描述
	     **/
	    private EnumOrderType(String status,String description) {
	        this.status = status;
	        this.description = description;
	    }

	    /**
	     * 根据描述查找枚举
	     * 
	     * @param description 编码
	     * @return EnumSTATUS
	     **/
	    public static EnumOrderType find(String description) {
	        for (EnumOrderType frs : EnumOrderType.values()) {
	            if (frs.getDescription().equals(description)) {
	                return frs;
	            }
	        }
	        return null;
	    }
	    /**
	     * 根据枚举查找描述
	     * 
	     * @param status 枚举
	     * @return String
	     **/
	    public static String getDescription(String status) {
	    	for (EnumOrderType frs : EnumOrderType.values()) {
	            if (frs.status.equals(status)) {
	                return frs.description;
	            }
	        }
			return status;
	    }
	    
	    public String getDescription() {
	        return description;
	    }
	}
	
	/**
	 * 交易状态枚举
	 */
	public enum EnumOrderState {
		IN_PROGRESS("IN_PROGRESS","进行中"),
		NON_PAYMENT("NON_PAYMENT","待支付"),
		SUCCESS("SUCCESS","成功"),
		FAIL("FAIL","失败"),
		GOODFAIL_IN_HAND("GOODFAIL_IN_HAND","流标回款处理中"),
		GOODFAIL_END("GOODFAIL_END","流标已回款"),
		SALE_CANCEL("SALE_CANCEL","取消"),
		SALE_CLOSE("SALE_CLOSE","关闭");
	    /** 状态描述 **/
	    private String description;
	    /** 状态 **/
	    private String status;

	    /**
	     * 私有构造方法
	     * @param description 描述
	     **/
	    private EnumOrderState(String status,String description) {
	        this.status = status;
	        this.description = description;
	    }

	    /**
	     * 根据描述查找枚举
	     * 
	     * @param description 编码
	     * @return EnumSTATUS
	     **/
	    public static EnumOrderState find(String description) {
	        for (EnumOrderState frs : EnumOrderState.values()) {
	            if (frs.getDescription().equals(description)) {
	                return frs;
	            }
	        }
	        return null;
	    }
	    /**
	     * 根据枚举查找描述
	     * 
	     * @param status 枚举
	     * @return String
	     **/
	    public static String getDescription(String status) {
	    	for (EnumOrderState frs : EnumOrderState.values()) {
	            if (frs.status.equals(status)) {
	                return frs.description;
	            }
	        }
			return status;
	    }
	    
	    public String getDescription() {
	        return description;
	    }
	}
	
	
	/**
	 * 订单状态（订单中心）枚举
	 */
	public enum EnumOrderCenterStatus {
		SALE_NEW("SALE_NEW","新建"),
//		SALE_CONFIRMED("SALE_CONFIRMED","确认"),
		SALE_CONFIRMED("SALE_CONFIRMED","待支付"),
		SALE_NOPAY("SALE_NOPAY","未支付"),
		SALE_PAYED("SALE_PAYED","支付成功"),
		SALE_CANCEL("SALE_CANCEL","订单取消"),
		SALE_CLOSE("SALE_CLOSE","订单关闭"),
		SALE_DEAL("SALE_DEAL","成功"),
		SALE_NODEAL("SALE_NODEAL","未完成"),
		SALE_PAYING("SALE_PAYING","支付中"),
		SALE_PAYFAILURE("SALE_PAYFAILURE","支付失败"),
		GOODFAIL_IN_HAND("GOODFAIL_IN_HAND","流标回款处理中"),
		GOODFAIL_END("GOODFAIL_END","流标已回款"),
		REPAYMENT_NEW("REPAYMENT_NEW","新建还款订单"),
		REPAYMENT_HANDLING("REPAYMENT_HANDLING","还款处理中"),
		REPAYMENT_FAIL("REPAYMENT_FAIL","还款失败"),
		REPAYMENT_SUCCESS("REPAYMENT_SUCCESS","还款成功"),
		CASH_NEW("CASH_NEW","新建兑付订单"),
		CASH_HANDLING("CASH_HANDLING","兑付中"),
		CASH_FAIL("CASH_FAIL","兑付失败"),
		CASH_SUCCESS("CASH_SUCCESS","兑付成功"),
		LOAN_NEW("LOAN_NEW","新建放款订单"), 
		LOAN_HANDLING("LOAN_HANDLING","放款中"),
		LOAN_FAIL("LOAN_FAIL","放款失败"), 
		LOAN_SUCCESS("LOAN_SUCCESS","放款成功");


	    /** 状态描述 **/
	    private String description;
	    /** 状态 **/
	    private String status;
	    /**
	     * 私有构造方法
	     * @param description 描述
	     **/
	    private EnumOrderCenterStatus(String status,String description) {
	    	this.status=status;
	        this.description = description;
	    }

	    /**
	     * 根据描述查找枚举
	     * 
	     * @param description 编码
	     * @return EnumSTATUS
	     **/
	    public static EnumOrderCenterStatus find(String description) {
	        for (EnumOrderCenterStatus frs : EnumOrderCenterStatus.values()) {
	            if (frs.getDescription().equals(description)) {
	                return frs;
	            }
	        }
	        return null;
	    }
	    /**
	     * 根据枚举查找描述
	     * 
	     * @param status 枚举
	     * @return String
	     **/
	    public static String getDescription(String status) {
	    	for (EnumOrderCenterStatus frs : EnumOrderCenterStatus.values()) {
	            if (frs.status.equals(status)) {
	                return frs.description;
	            }
	        }
			return status;
	    }
	    
	    public String getDescription() {
	        return description;
	    }
	}
	
	
}
